<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'order-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>
    
    <h3> <?php echo 'Transporter'; ?> </h3>
    <?php if ($model->status == 1){ ?>
    <p> <?php echo 'Choose your Transporter'; ?> </p>
    <?php
    $i = 0;
    $vehicles = TransporterVehicle::model()->findAllByAttributes(array('method_id' => $model->transporter_method));
    foreach($vehicles as $method) {
        $transporter = Users::model()->findByPk($method->transporter_id);
        echo '<div class="row">';
        echo CHtml::radioButton("Transporter[id]", $i == 0, array(
                    'value' => $method->transporter_id));
        echo '<div class="float-left">';
        echo CHtml::label($transporter->username, 'PaymentMethod');
        echo CHtml::tag('p', array(), $method->amount);
        echo '</div>';
        echo '</div>';
        echo '<div class="clear"></div>';
        $i++;
    }
        echo '<div class="row">';
        echo CHtml::label('Amount', 'amount vehicle');
        echo CHtml::textField("Transporter[amount]", 1);
        echo '</div>';
        echo '<div class="clear"></div>';
        echo '<div class="row">';
        echo CHtml::label('Price', 'transporter price');
        echo CHtml::textField("Transporter[price]");
        echo '</div>';
        echo '<div class="clear"></div>';
	?>
    <?php }else { 
        echo '<div class="row">';
        echo '<div>';
        echo CHtml::label('Transporter:', '');
        echo CHtml::tag('p', array(), Users::model()->findByPk($model->getOrderTransporter()->transporter_id )->username);
        echo '</div>';
        
        echo '<div>';
        echo CHtml::label('Amount:', 'amount vehicle');
        echo CHtml::tag('p', array(), $model->getOrderTransporter()->amount );
        echo '</div>';
        
        echo '<div>';
        echo CHtml::label('Price:', '');
        echo CHtml::tag('p', array(), $model->getOrderTransporter()->price );
        echo '</div>';
        
        echo '</div>';
        echo '<div class="clear"></div>';    
     } ?>
    
    <h3> <?php echo Shop::t('Order Info'); ?> </h3>
	<p class="note">Fields with <span class="required">*</span> are required.</p>
	<div class="row">
		<?php echo $form->labelEx($model,'buying_price'); ?>
		<?php echo $form->textField($model,'buying_price'); ?>
		<?php echo $form->error($model,'buying_price'); ?>
	</div>

    <div class="row">
        <?php echo $form->labelEx($model, 'shipping_price'); ?>
        <?php echo $form->textField($model, 'shipping_price');?>
        <?php echo $form->error($model,'shipping_price'); ?>
    </div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->